<?php require_once('Connections/hitekforyou.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_sanpham = 12;
$pageNum_sanpham = 0;
if (isset($_GET['pageNum_sanpham'])) {
  $pageNum_sanpham = $_GET['pageNum_sanpham'];
}
$startRow_sanpham = $pageNum_sanpham * $maxRows_sanpham;

$colname_sanpham = "-1";
if (isset($_GET['idSP'])) {
  $colname_sanpham = $_GET['idSP'];
}
mysql_select_db($database_hitekforyou, $hitekforyou);
$query_sanpham = sprintf("SELECT * FROM sanpham WHERE idSP = %s", GetSQLValueString($colname_sanpham, "int"));
$query_limit_sanpham = sprintf("%s LIMIT %d, %d", $query_sanpham, $startRow_sanpham, $maxRows_sanpham);
$sanpham = mysql_query($query_limit_sanpham, $hitekforyou) or die(mysql_error());
$row_sanpham = mysql_fetch_assoc($sanpham);

if (isset($_GET['totalRows_sanpham'])) {
  $totalRows_sanpham = $_GET['totalRows_sanpham'];
} else {
  $all_sanpham = mysql_query($query_sanpham);
  $totalRows_sanpham = mysql_num_rows($all_sanpham);
}
$totalPages_sanpham = ceil($totalRows_sanpham/$maxRows_sanpham)-1;

$colname_ChiTietSP = "-1";
if (isset($_GET['idSP'])) {
  $colname_ChiTietSP = $_GET['idSP'];
}
mysql_select_db($database_hitekforyou, $hitekforyou);
$query_ChiTietSP = sprintf("SELECT * FROM chitietsp WHERE idSP = %s", GetSQLValueString($colname_ChiTietSP, "int"));
$ChiTietSP = mysql_query($query_ChiTietSP, $hitekforyou) or die(mysql_error());
$row_ChiTietSP = mysql_fetch_assoc($ChiTietSP);
$totalRows_ChiTietSP = mysql_num_rows($ChiTietSP);


$queryString_sanpham = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_sanpham") == false && 
        stristr($param, "totalRows_sanpham") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_sanpham = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_sanpham = sprintf("&totalRows_sanpham=%d%s", $totalRows_sanpham, $queryString_sanpham);

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_hitekforyou);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "thoat");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "Index.php");
// Add columns
// End of logout transaction instance

// Make a login transaction instance
$loginTransaction = new tNG_login($conn_hitekforyou);
$tNGs->addTransaction($loginTransaction);
// Register triggers
$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "dangnhap");
$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");
// Add columns
$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "user_name");
$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "user_pass");
// End of login transaction instance

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);


$TFM_LimitLinksEndCount = 12;
$TFM_temp = $pageNum_sanpham + 1;
$TFM_startLink = max(1,$TFM_temp - intval($TFM_LimitLinksEndCount/2));
$TFM_temp = $TFM_startLink + $TFM_LimitLinksEndCount - 1;
$TFM_endLink = min($TFM_temp, $totalPages_sanpham + 1);
if($TFM_endLink != $TFM_temp) $TFM_startLink = max(1,$TFM_endLink - $TFM_LimitLinksEndCount + 1);


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang chủ</title>
<link href="css.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="stmenu.js"></script>
<script src="AC_RunActiveContent.js" type="text/javascript"></script>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<script>
function chonSP()
{
}
</script>
</head>

<body>
<div id="container">
  <div id="header">
   <?php include("banner.php"); ?> 
  </div>
  <div id="menu">
   <script type="text/javascript" src="menu.js"></script>

  </div>
  <div id="main">
    <!-- Start Div Left Main -->
    <?php include("leftmain.php"); ?>
        <!-- End Div Left Main -->
    <!-- Start Div right Main -->
   <div id="rightmain">


    <?php
//Show If User Is Logged In (region1)
$isLoggedIn = new tNG_UserLoggedIn($conn_hitekforyou);
//Grand Levels: Level
if ($isLoggedIn->Execute()) {
?>
<form id="DangXuat" name="dangxuat" method="post" action="">
          <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
            <tbody>
              <tr>
                <td align="center"><img src="images/dang-nhap.jpg" alt="6" width="184" height="41" /></td>
              </tr>
              <tr>
                <td height="170" valign="top" background="images/dang-nhap-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                      <tr>
                        <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                              <tr>
                                <td><div align="center"><strong>Chào
                                    <?php echo $_SESSION['kt_TenKH']; ?> </strong></div></td>
                              </tr>
                              <tr>
                                <td height="8"><img src="images/spacer.gif" alt="5" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center"><strong><a href="doithongtincanhan.php" class="lienket">Đổi thông tin cá nhân</a></strong></div></td>
                              </tr>
                              <tr>
                                <td height="5"><img  src="images/spacer.gif" alt="4" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" alt="3" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td height="5"><img  src="images/spacer.gif" alt="2" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td height="5" align="center"><?php
	echo $tNGs->getErrorMsg();
?><input type="submit" name="thoat" id="button2" value="Thoát" onclick="funABC()" /></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" alt="1" width="1" height="1" /></td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                      <tr>
                        <td valign="top"><label>
                            <div align="center"></div>
                          </label></td>
                      </tr>
                    </tbody>
                  </table>
                    <label>
                    <div align="center"></div>
                  </label></td>
              </tr>
            </tbody>
          </table>
            </form>


      <?php 
// else Show If User Is Logged In (region1)
} else { ?>
      <form id="DangNhap" name="DangNhap" method="post" action="">
          <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
            <tbody>
              <tr>
                <td align="center"><img src="images/dang-nhap.jpg" width="184" height="41" /></td>
              </tr>
              <tr>
                <td height="170" valign="top" background="images/dang-nhap-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                      <tr>
                        <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                              <tr>
                                <td><div align="center"><strong>Tên đăng nhập</strong></div></td>
                              </tr>
                              <tr>
                                <td height="8"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  <input type="text" name="user_name" id="user_name" />
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center"><strong>Mật khẩu</strong></div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  <input type="password" name="user_pass" id="user_pass" />
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td height="5" align="center"><input type="submit" name="dangnhap" id="button" value="Đăng nhập" /></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                    </tbody>
                  </table>
                    <label>
                    <div align="center"></div>
                  </label></td>
              </tr>
            </tbody>
          </table>
        </form> <!-- End Form Đăng nhập -->
  <?php
}
//End Show If User Is Logged In (region1)
?>

<div id="giohang">
         <?php include "hiengiohang.php"; ?>
        </div>

     <!-- End Div Gio Hang -->   
        
      <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
        <tbody>
          <tr>
            <td align="center"><img src="images/tin-moi-nhat.jpg" width="184" height="40" /></td>
          </tr>
          <tr>
            <td height="226" valign="top" background="images/tin-moi-nhat-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                  <tr>
                    <td>
<div style="height:200px;">
<marquee behavior="scroll" direction="up" height="200px" scrolldelay="700">
<div style="padding-bottom:2px; padding-top:5px;padding-left:5px;"><img src="images/arrow2.gif" width="9" height="7" />Tin mới</div>
</marquee>
</div></td>
                  </tr>
                </tbody>
            </table></td>
          </tr>
        </tbody>
      </table> <!-- End Table Tin tuc -->
    </div>
        <!-- End Div right Main -->
    <div id="content">
   <table width="600" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr>
          <td><table width="600" border="0" align="center" cellpadding="0" cellspacing="0" id="IPad">
            <tbody>
              <tr>
                <td valign="top" bgcolor="#FFFFFF"><div>
                    <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" id="main2">
                      <tr>
                        <td><table width="100%" border="0" cellpadding="0" cellspacing="0" id="IPad2">
                            <tbody>
                              <tr>
                                <td width="9"><img src="images/bc-t-l.gif" width="9" height="9" /></td>
                                <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                <td width="11"><img src="images/bc-t-r.gif" width="11" height="9" /></td>
                              </tr>
                              <tr>
                                <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                <td align="left" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                      <tbody>
                                        
                                        <tr>
                                          <td><table border="0" bordercolor="#111111" cellpadding="0" cellspacing="0" width="100%">
                                            <tbody>
                                              <tr>
                                                <td width="100%" align="center" class="normal"><table id="table18" border="1" width="100%">
                                                    <tbody>
                                                      <tr>
                                                        <td align="center" bgcolor="#f5f5f5" valign="top" width="20%"><table id="table20" style="border-collapse: collapse;" border="0" bordercolor="#111111" cellpadding="2" cellspacing="0" width="100%">
                                                            <tbody>
                                                              <tr>
                                                                <td class="releaseTitle" align="center" height="23"><font color="#ff0000"><span class="news_link_title"><?php echo $row_sanpham['TenSP']; ?></span></font></td>
                                                              </tr>
                                                              <tr>
                                                                <td><table style="border-collapse: collapse;" id="AutoNumber105" border="1" bordercolor="#b0bec7" cellpadding="0" cellspacing="0" width="100%">
                                                                    <tbody>
                                                                      <tr>
                                                                        <td class="normal" align="center" bgcolor="#ffffff" width="100%" height="20"><img src="UploadImage/SanPham/<?php echo $row_sanpham['HinhAnh']; ?>" width="125" height="125" border="0" /> </td>
                                                                      </tr>
                                                                    </tbody>
                                                                </table></td>
                                                              </tr>
                                                              <tr>
                                                                <td height="6"></td>
                                                              </tr>
                                                              <tr>
                                                                <td width="100%" height="10"><table style="border-collapse: collapse;" background="Nokia files/imgBG3.gif" border="1" bordercolor="#b0bec7" cellpadding="0" cellspacing="0" width="100%">
                                                                    <tbody>
                                                                      <tr>
                                                                        <td class="normal" align="center" width="100%"><font color="red"><span class="gia" style="color:#FF0000; font-weight:bold;"><?php echo number_format($row_sanpham['DonGia']); ?>&nbsp;VNĐ</span></font></td>
                                                                      </tr>
                                                                    </tbody>
                                                                </table>
                                                                  <p align="center"><img onclick="chonSP('chonsp.php?idSP=<?php echo $row_sanpham['idSP']; ?>')" src="images/datmua.gif" width="67" height="20" /></p></td>
                                                              </tr>
                                                              <tr>
                                                                <td height="2"></td>
                                                              </tr>
                                                            </tbody>
                                                        </table></td>
                                                        <td align="left" valign="top" width="80%"><table width="100%" border="0" style="margin-top:5px;">
                                                            <tbody>
                                                              <tr>
                                                                <td width="63%"><table id="table19" style="border-collapse: collapse;" border="0" width="100%">
                                                                    <tbody>
                                                                      <tr>
                                                                        <td colspan="2" bgcolor="#eeeeee" height="1"></td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td colspan="2" bgcolor="#eeeeee" height="1"></td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td class="cell" height="20">&nbsp;</td>
                                                                        <td class="titleDetail1" height="20">&nbsp;</td>
                                                                      </tr>

                                                                      <tr>
                                                                        <td class="cell" width="40%" height="20">&nbsp;</td>
                                                                        <td class="titleDetail1" width="82%" height="20">&nbsp;</td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td colspan="2" bgcolor="#eeeeee" height="1"></td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td class="cell" width="40%" height="20">&nbsp;<img src="images/arrow2.gif" /><b> Số lượng còn</b></td>
                                                                        <td class="titleDetail1" width="82%" height="20"><?php echo $row_sanpham['SoLuongTonKho']; ?></td>
                                                                      </tr>
                                                                      <tr>
                                                                        <td colspan="2" bgcolor="#eeeeee" height="1"></td>
                                                                      </tr>
                                                                    </tbody>
                                                                    <tbody>
                                                                    </tbody>
                                                                </table></td>
                                                              </tr>
                                                              <tr>
                                                                <td height="3px;"></td>
                                                              </tr>
                                                            </tbody>
                                                        </table>
                                                          <p align="right"><a href="javascript:history.go(-1)">Trở lại</a></p>
                                                          <form id="form1" name="form1" method="post" action="">
                                                            <input name="idSP" type="hidden" id="idSP" value="<?php echo $row_sanpham['idSP']; ?>" />
                                                          </form>
                                                          </td>
                                                      </tr>
                                                      
                                                    </tbody>
                                                  </table>
                                                  <br />
                                                    <table id="table108" style="border-collapse: collapse;" border="1" bordercolor="#b0bec7" cellpadding="0" cellspacing="0" width="100%">
                                                      <tbody>
                                                        <tr>
                                                          <td bordercolor="#B0BEC7" background="Nokia files/imgBG4a.gif" height="25"><b><font color="#16387c" face="Arial">&nbsp; <font size="2"> Thông tin chi tiết về <?php echo $row_sanpham['TenSP']; ?></font></font></b></td>
                                                        </tr>
                                                      </tbody>
                                                  </table>
                                                    
                                                    <table width="95%" border="1" cellpadding="2" cellspacing="0" bordercolor="#666666" id="chitiet">
                                                      <tr>
                                                        <td width="26%" bordercolor="#333333">Chipset</td>
                                                        <td width="74%" bordercolor="#333333"><?php echo $row_ChiTietSP['Chipset']; ?></td>
                                                      </tr>
                                                      <tr>
                                                       
                                                        <td bordercolor="#333333">CPU</td>
                                                        <td bordercolor="#333333"><?php echo $row_ChiTietSP['CPU']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        <td bordercolor="#333333">RAM</td>
                                                        <td bordercolor="#333333"><?php echo $row_ChiTietSP['Ram']; ?></td>
                                                      </tr>
                                                      <tr>
                                                       
                                                        <td bordercolor="#999999">Màn hình</td>
                                                        <td bordercolor="#999999"><?php echo $row_ChiTietSP['Manhinh']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        <td bordercolor="#999999">HDD</td>
                                                        <td bordercolor="#999999"><?php echo $row_ChiTietSP['HDD']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        
                                                        <td bordercolor="#999999">CD-Rom</td>
                                                        <td bordercolor="#999999"><?php echo $row_ChiTietSP['CDRom']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        <td bordercolor="#999999">Card Màn hinh</td>
                                                        <td bordercolor="#999999"><?php echo $row_ChiTietSP['CardManhinh']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        <td bordercolor="#999999">Wifi</td>
                                                        <td bordercolor="#999999"><?php echo $row_ChiTietSP['Wifi']; ?></td>
                                                      </tr>
                                                      <tr>
                                                        
                                                      </tr>
                                                      <tr>
                                                      
                                                        
                                                     </tr>
                                                  </table></td>
                                              </tr>
                                            </tbody>
                                          </table></td>
                                        </tr>
                                      </tbody>
                                  </table></td>
                                <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><img src="images/bc-u-l.gif" width="9" height="11" /></td>
                                <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                <td><img src="images/bc-u-r.gif" width="11" height="11" /></td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                    </table>
                </div></td>
              </tr>
            </tbody>
          </table></td>
        </tr>
      </table>
  
    </div> <!-- End div content -->
  </div><!-- End div Main -->
  <div id="footer">
  <?php include("footer.php"); ?>
  </div>
</div>
</body>
</html>
<?php
mysql_free_result($sanpham);

mysql_free_result($ChiTietSP);
?>
